/**
 * 
 */
package com.arx.script.flyweight;

/**
 * @author Donald
 */
public final class ScriptVariable {
	/** the floating-point value the {@link ScriptVariable} references. */
	private float	fval;
	/** the integer value the {@link ScriptVariable} references. */
	private long	ival;
	private byte[]	name;
	private byte[]	text;	// for a TEXT type ival equals strlen(text).
	private int	type;
	/** Clears up member fields, releasing their memory. */
	public void clear() {
		name = text = null;
	}
	/**
	 * Gets the floating-point value the {@link ScriptVariable} references.
	 * @return float
	 */
	public float getFval() {
		return fval;
	}
	/**
	 * Gets the integer value the {@link ScriptVariable} references.
	 * @return long
	 */
	public long getIval() {
		return ival;
	}
	/**
	 * Gets the name
	 * @return {@link String}
	 */
	public String getName() {
		return new String(name);
	}
	/**
	 * Gets the text
	 * @return {@link String}
	 */
	public String getText() {
		return new String(text);
	}
	public int getType() {
		return type;
	}
	/**
	 * Determines if the script variables have a text component.
	 * @return true if the script variables have a text component; false
	 *         otherwise
	 */
	public boolean hasText() {
		boolean has = false;
		if (text != null && text.length > 0) {
			has = true;
		}
		return has;
	}
	/**
	 * Sets the floating-point value the {@link ScriptVariable} references.
	 * @param val the floating-point value to set
	 */
	public void setFval(final float val) {
		fval = val;
	}
	/**
	 * Sets the ival
	 * @param val the ival to set
	 */
	public void setIval(final long val) {
		ival = val;
	}
	/**
	 * Sets the name
	 * @param val the name to set
	 */
	public void setName(final String val) {
		name = val.getBytes();
	}
	/**
	 * Sets the text component for the script variable.
	 * @param val the text to be set
	 */
	public void setText(final String val) {
		text = val.getBytes();
	}
	public void setType(final int val) {
		type = val;
	}
}
